package ddb.tasktracker.intf.shared.http;

import org.springframework.http.ResponseEntity;

public class BaseResponse {

	private int code;
	private String message;
	private Object extra;

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public BaseResponse code(int code) {
		this.code = code;
		return this;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public BaseResponse message(String message) {
		this.message = message;
		return this;
	}

	public Object getExtra() {
		return extra;
	}

	public void setExtra(Object extra) {
		this.extra = extra;
	}

	public BaseResponse extra(Object extra) {
		this.extra = extra;
		return this;
	}

	public ResponseEntity<BaseResponse> toEntity() {
		return ResponseEntity.ok(this);
	}

	public static BaseResponse create() {
		BaseResponse r = new BaseResponse();
		return r;
	}

	public static BaseResponse create(int code) {
		BaseResponse r = new BaseResponse();
		r.code = code;
		return r;
	}

	public static BaseResponse create(int code, String message) {
		BaseResponse r = new BaseResponse();
		r.code = code;
		r.message = message;
		return r;
	}

	public static BaseResponse create(int code, String message, Object extra) {
		BaseResponse r = new BaseResponse();
		r.code = code;
		r.message = message;
		r.extra = extra;
		return r;
	}

	public static BaseResponse create(int code, Object extra) {
		BaseResponse r = new BaseResponse();
		r.code = code;
		r.extra = extra;
		return r;
	}

	public static BaseResponse create(Object extra) {
		BaseResponse r = new BaseResponse();
		r.extra = extra;
		return r;
	}
}
